package com.qinghuan.mvc.controller;

import com.qinghuan.mvc.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Author: dubao
 * @Date: 2022/3/26 13:04
 * @Description:
 */
@Controller
public class UserController {

    /**
     * 使用RESTFul模拟用户资源的增删改查
     * /user  GET   查询所有用户信息
     * /user/id  GET   根据用户id查询用户信息
     * /user  POST   添加用户信息
     * /user/id  DELETE   删除用户信息
     * /user  PUT   更新用户信息
     */

    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public String getAllUser() {
        System.out.println("查询所有用户信息：");

        return "success";
    }

    @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
    public String getUserById(@PathVariable String id) {
        System.out.println("根据id查询用户信息");
        return "success";
    }

    @RequestMapping(value = "/user", method = RequestMethod.POST)
    public String addUser(String username, String password) {
        System.out.println("添加用户信息：" + username + "," + password);
        return "success";
    }

    @RequestMapping(value = "user", method = RequestMethod.PUT)
    public String updateUser(User user) {
        System.out.println("修改用户信息：" + user.getUsername() + "," + user.getPassword());
        return "success";
    }

}
